<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>await并行执行技巧</title>
  </head>
  <body></body>
  <script>
    function h1() {
      return new Promise((resolve) => {
        setTimeout(() => {
          resolve("houdunren");
        }, 2000);
      });
    }
    function h2() {
      return new Promise((resolve) => {
        setTimeout(() => {
          resolve("hdcms");
        }, 2000);
      });
    }
    async function hd() {
      let res = await Promise.all([h1(), h2()]);
      console.log(res);
      // let p1 = h1();
      // let p2 = h2();
      // let p1value = await p1; //then
      // let p2value = await p2;
      // console.log(p1value, p2value);
    }
    hd();
  </script>
</html>
